package createModel.factoryModel.simple;

public class FruitFactory {
    public static Fruit getFruit(String fruitName) {
        Fruit fruit = null;
        if (fruitName.equals("apple")) {
            fruit = new Apple();
        } else if (fruitName.equals("banana")) {
            fruit = new Banana();
        } else if (fruitName.equals("strawberry")) {
            fruit = new Strawberry();
        } else if (fruitName.equals("watermelon")) {
            fruit = new Watermelon();
        }// else if (fruitName.equals("Grape")) {
        //     fruit = new Bicycle();
        //} // 如果想要新增新的fruit，就在这里添加 但是在工作中，我们一般不这么做，因为这样会导致代码的可维护性变差
        return fruit;
    }
}
